﻿#ifndef MEMORYPOOL_H
#define MEMORYPOOL_H

#include <stdint.h>
#include <vector>
#include "memory_chunk.h"

namespace RemoteObj
{
struct HeapHeader
{
    int32_t size;
};

struct MemoryHeap
{
    HeapHeader header;
    int8_t buffer;
};

class MemoryPool
{
public:
    enum {MAX_SIZE = 1024,
          MIN_SIZE = sizeof(RemoteObj::MemoryChunk*)
         };
    MemoryPool();
    ~MemoryPool();
    void* malloc(int32_t size);
    void free(void* mem);
protected:
    void* do_malloc(int32_t size);
    bool do_free(void* mem);
private:
    RemoteObj::MemoryChunk ** _chunk_list;
    int32_t _chunk_count;
};
}

#endif // MEMORYPOOL_H
